﻿using AuthenticationMVC.Adapters.Interfaces;
using AuthenticationMVC.Data;
using AuthenticationMVC.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AuthenticationMVC.Adapters.Adapters
{
    public class ToDoAdapter : IToDoAdapter
    {
        public List<ToDo> GetAllToDos(string userId)
        {
            List<ToDo> model;
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                model = db.ToDos.Where(x => x.UserId == userId && x.DateCompleted == null).ToList();
            }
            return model;
        }
        public void CreateToDo(ToDo model)
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                db.ToDos.Add(model);
                db.SaveChanges();
            }
        }
    }
}